<script setup>
import Sku from "../Sku/Sku.vue";
import axios from "axios";
import { onMounted, ref } from "vue";

// 商品数据
const goods = ref({});
// sku对象
let sku = ref({});
// 获取商品数据
const getGoods = async () => {
  // 1135076  初始化就有无库存的规格
  // 1369155859933827074 更新之后有无库存项（蓝色-20cm-中国）
  const res = await axios.get(
    "http://pcapi-xiaotuxian-front-devtest.itheima.net/goods?id=1369155859933827074"
  );
  goods.value = res.data.result;
};
onMounted(() => getGoods());
</script>

<template>
  <Sku v-model="sku" v-if="goods.id" :goods="goods" />
  <button @click="console.log(sku)">点我</button>
</template>

<style scoped></style>
